#include "qmsg.h"

//add by dimon, 2024-03-17 11:48

QMsg::QMsg(QObject *parent) : QObject(parent)
{
    tarIP = 0;
    tarPort = 0;
}


QMsg::~QMsg()
{

}
 //打包消息数据
void QMsg::pack(){
    QDataStream out(&buf, QIODevice::WriteOnly);
    out.setVersion(QDataStream::Qt_5_4);

    //'<<'插入运算符，把type, senderId, strInfo 插入QDataStream流
    out << type << senderID << strInfo;
}

//解包消息数据
bool QMsg::load(){
    QDataStream in(&buf, QIODevice::ReadOnly);
    in.setVersion(QDataStream::Qt_5_4);

    //'>>'提取云算法，把type, senderId, strInfo从 QDataStream流中提取
    in >> type >> senderID >> strInfo;

    return true;
}

